<?php
/**
 * Created by PhpStorm.
 * User: geolo
 * Date: 2018/10/22
 * Time: 16:59
 */
namespace app\modules\mch\models;
use app\models\Split;
/**
 * @property Split $model
 * @property Store $store
 */
class SplitForm extends Model
{
    public $store_id;
    public $color;
    public $name;
    public $height;
    public $is_delete;
    public $model;

    public function rules()
    {
        return[

            [['store_id','name','color','height'],'required'],
            [['name','color','height'],'string'],
            [['store_id','is_delete'],'integer'],
        ];
    }
    public function attributeLabels()
    {
        return[
            'name'=>'名称',
            'color'=>'颜色',
            'height'=>'高度',
            'store_id'=>'Store_id',
        ];
    }
    public function save()
    {
        if(!$this->validate()){
            return $this->getModelError();
        }
        $this->model->name = $this->name;

        $this->model->color= $this->color;
        $this->model->height = $this->height;
        if ($this->model->isNewRecord) {
            $this->model->store_id = $this->store_id;
            $this->model->is_delete = 0;
        }
//        var_dump($this->model);
        if ($this->model->save())
            return [
                'code' => 0,
                'msg' => '保存成功',
            ];
        else
            return $this->getModelError($this->model);
    }
}